<template>
  <div class="MenuBox">
    <!--  <div style="display: flex;align-items: center;justify-content: center;">
      <img style="width: 60%;height: auto;margin: 10px 5px 5px 0;" src="../assets/image/qmCare.png" />
    </div> -->
    <div style="display: flex;align-items: center;justify-content: center;">
      <img style="width: 20%;height: auto;margin: 10px 5px 5px 0;" src="../assets/image/jsDoctor.jpg" />
      <h3>京山市人民医院</h3>
    </div>

    <el-menu :router="true" :unique-opened="true" active-text-color="#409eff" class="menu" ref="elMenuRef"
      :default-active="$route.meta.belong ? $route.meta.belong : $route.path">
      <template v-for="(firstItem, firstIndex) in menuList">
        <el-submenu v-if="firstItem.children" :index="firstItem.path" :key="firstIndex">
          <template slot="title">
            <!--   <img
              style="
                width: 20px;
                height: 20px;
                margin-right: 5px;
                border-radius: 50%;
              "
              src="../assets/image/jsDoctor.jpg"
            /> -->
            <span>{{ firstItem.label }}</span>
          </template>

          <el-menu-item v-for="(secondItem, secondIndex) in firstItem.children" :key="secondIndex"
            :index="secondItem.path">
            <span>{{ secondItem.label }}</span>
          </el-menu-item>
        </el-submenu>

        <el-menu-item v-else :index="firstItem.path" :key="firstIndex">
          <!-- <img
            style="
              width: 20px;
              height: 20px;
              margin-right: 5px;
              border-radius: 50%;
            "
            src="../assets/image/jsDoctor.jpg"
          /> -->
          <span>{{ firstItem.label }}</span>
        </el-menu-item>
      </template>
    </el-menu>
    <div class="welcome">
      <svg-icon icon-class="smile" size="26" />
      <span class="ml10">欢迎您，{{ userState.name }}！</span>
    </div>
    <div class="exitClass">
      <div @click="changePassword">修改密码</div>
      <div @click="exit">退出登录</div>
    </div>
    <password ref="pass"></password>
  </div>
</template>

<script>
import { mapState, mapGetters } from "vuex";
import bus from "@/bus";
import password from "./changePassword.vue";
export default {
  components: { password },
  data() {
    return {};
  },
  computed: {
    ...mapState(["userState"]),
    ...mapGetters(["menuList"]),
  },
  mounted() { },
  methods: {
    changePassword() {
      this.$refs.pass.show();
    },
    exit() {
      bus.$emit("loginOut");
      sessionStorage.clear();
      window.location.reload();
    },
    outLogin() {
      this.$alert("确认退出登录？", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
        center: true,
      }).then(() => {
        this.$Socket.action("loginOut", "", (res) => { });
        this.$cookies.remove("token");
        sessionStorage.removeItem("token");
        this.$cookies.remove("cookiesAdminUser");

        this.setToken("");
        this.delUser();
        this.$message({
          type: "success",
          message: "退出成功!",
        });
        setTimeout(() => {
          this.$router.push({
            path: "/login",
          });
        }, 1000);
      });
    },
  },
};
</script>

<style lang="less" scoped>
.MenuBox {
  background: #fff;
  height: 100%;
  overflow-x: hidden;
  ::-webkit-scrollbar {
    display: none;
  }
  .menu {
    height: 86%;
    padding-bottom: 20px;
    border-right: none;
    overflow: auto;

    /deep/ .el-submenu__title,
    .el-menu-item {
      font-size: 16px;
      user-select: none;
    }
    /deep/.is-opened {
      .el-submenu__title {
        background: #dce9ff;
      }
      .el-menu {
        background: #f2f7ff;

        .el-menu-item {
          color: #a0a0a0;
        }
      }
    }
  }
  .icon {
    width: 90%;
    height: 40px;
    padding: 5px;
  }

  .welcome {
    width: 100%;
    font-weight: 600;

    display: flex;
    align-items: center;
    // text-align: center;
    padding-left: 20px;
    margin-bottom: 5px;
    // border: 1px solid green;
  }
  .menu-itemCount {
    width: 18px;
    display: inline-block;
    height: 18px;
    line-height: 18px;
    margin-left: 10px;
    border-radius: 16px;
    background: #df3737;
    text-align: center;
    font-size: 12px;
    color: #fff;
    // padding: 3px;
  }
  /deep/ .el-badge__content.is-fixed {
    top: 20px;
    right: -2px;
  }
  .exitClass {
    display: flex;
    justify-content: space-evenly;
    color: #409eff;
    cursor: pointer;
    user-select: none;
  }
}
</style>
